<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class WxUser extends Model
{
    public $fillable = [
        'user_id',
    	'open_id',
        //当前使用设备编码
        'current_device_code',
    	'nickname',
    	'head_img_url',
    	'is_subscribe',
    	'sex',
    	'city',
    	'province',
    	'country',
    	'language',
    	'subscribe_time',
    ];
    
    public $primaryKey = 'user_id';

    public $timestamps = false;

    public function wxUserDevices(){
        return $this->hasMany('App\Models\WxUserDevice', 'user_id', 'user_id');
    }

    public function devices(){
        return $this->belongsToMany('App\Models\Device', 'wx_user_devices', 'user_id', 'device_id');
    }

    public function user(){
        return $this->belongsTo('App\Models\User');
    }

    public function userInfo(){
        return $this->hasOne('App\Models\UserInfo', 'user_id', 'user_id');
    }
}
